import instance from "@/tools/axios";

// 根据字典类别编号获取其下的字典列表
const getDictionaryListByDictionaryTypeKey = (key: string) => {
  return instance.get("/Dictionarys/GetDictionaryListByDictionaryTypeKey", {
    key,
  });
};
// 根据字典类别名称获取其下的字典树
const getDictionaryTreeByDictionaryTypeKey = (key: string) => {
  return instance.get("/Dictionarys/GetDictionaryTreeByDictionaryTypeKey", {
    key,
  });
};

// 根据父级编号获取其下的子级字典列表
const getDictionaryListByParentId = (parentId: string) => {
  return instance.get("/Dictionarys/GetDictionaryListByParentId", {
    parentId,
  });
};

const detailDictionary = (id: string) => {
  return instance.get("/Dictionarys/Detail", { id });
};

const addDictionary = (data: any) => {
  return instance.post("/Dictionarys/Add", data);
};
const deleteDictionary = (id: string) => {
  return instance.post("/Dictionarys/Delete", { id });
};
const updateDictionary = (data: any) => {
  return instance.post("/Dictionarys/Update", data);
};

export {
  getDictionaryListByParentId,
  getDictionaryListByDictionaryTypeKey,
  getDictionaryTreeByDictionaryTypeKey,
  addDictionary,
  deleteDictionary,
  updateDictionary,
  detailDictionary,
};
